package com.woniuxy.mybatisstudy.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @Author: linKe
 * @Date: 2021/11/23 19:52
 * @FileName: MyBatisConfig
 * @version: 1.0
 * @Description: 配置乐观锁  增加事务
 */
@EnableTransactionManagement
@Configuration
@MapperScan("com.woniuxy.mybatisstudy.mapper")
public class MyBatisConfig {
    /**
     * @return  注册乐观锁插件
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return interceptor;
    }
}
